package com.dong.pointandviewpager.sample.activity

import android.graphics.Color
import android.os.Bundle
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import com.dong.pointandviewpager.R
import com.dong.pointandviewpager.sample.factory.DataFactory.newDataBeans
import com.dong.pointandviewpager.sample.factory.ListenerFactory.newChangedListener
import com.dong.pointandviewpager.sample.factory.ListenerFactory.newClickListener
import com.dong.pointandviewpager.sample.model.ModelBean
import com.dong.pointviewpager.widget.LoopViewPager
import com.dong.pointviewpager.widget.PointView
import kotlinx.android.synthetic.main.activity_looper.*
import kotlinx.android.synthetic.main.activity_point.*

class PointActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_point)

        initLoopViewPager()
        initPointView()
    }

    private fun initLoopViewPager() {
        //配置LoopViewPager参数
        var loopViewPager = pointViewPager.loopViewPager as LoopViewPager<ModelBean>
       loopViewPager?.run {
            setLoop(true)
            setAuto(false)
            setRadius(2f)
            setImageScale(ImageView.ScaleType.CENTER_CROP)
            onLoopPageChangeListener = newChangedListener()
            onLoopPagerClickListener = newClickListener()
            beans = newDataBeans()
            initialise()
        }
    }

    private fun initPointView() {
        pointViewPager.pointView?.run{
            setNFColor(Color.RED) //设置未被选中时小圆点的颜色(默认白色)
            setFColor(Color.BLUE) //设置选中时小圆点的演的（默认红色）
            setDisBottom(10f) //设置距离控件底部的距离
            setDistance(8f) //设置小圆点之间的间隔距离
            setRadius(3f) //设置小圆点的半径
            scrollType = PointView.SMOOTH_SCROLL //设置小圆点的滑动方式（INSTANT_SCROLL或SMOOTH_SCROLL）
            initialise()
        }
    }
}